package ChaiPiao.util;

public class StringUtil {
    public static String dealWithString(String str) {
        if (null == str) {
            str = "";
        }
        str = str.trim();
        return str;
    }

    /**
     * @param str
     * @return string will be trimed .if str is null  return true;
     */
    public static boolean isEmptyIncludeNull(String str) {
        str = dealWithString(str);
        return str.isEmpty();
    }

    public static boolean isInteger(String str) {
        try {
            Long.valueOf(str);
            return true;
        } catch (NumberFormatException e) {
            return false;
        }
    }

    public static int toInt(String str) {
        return Integer.valueOf(str);
    }

    /**
     * 68.123 to 68
     *
     * @param str
     * @return
     */
    public static String doubleStrToLongStr(String str) {
        String result = str.split("\\.")[0];
        return result;
    }

}
